﻿#pragma once

#include <string>
#include <vector>
#include <iostream>
#include <stdexcept>
#include "exceptionhelper.h"

namespace Server::Library::Utils
{
    class HttpService
    {
    protected:
        std::string Host;
    private:
        HttpListener *_listener;
        bool _isActive = true;

    public:
        virtual ~HttpService()
        {
            delete _listener;
        }

    protected:
        HttpService();

    public:
        void Listen();

        void Stop();

        virtual void OnGetRequest(HttpListenerRequest *request, HttpListenerResponse *response) = 0;
        virtual void OnPostRequest(HttpListenerRequest *request, HttpListenerResponse *response) = 0;

        void WriteResponse(HttpListenerResponse *response, const std::string &responseString);
    };
}
